package com.youlv.yl.dao;

import com.youlv.yl.dto.HotelCartItemDto;
import com.youlv.yl.entity.hotel.HotelCartItem;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author fenghe
 * @since 2022-01-19
 */
@Repository
public interface HotelCartItemDao extends BaseMapper<HotelCartItem> {

    /** 查询我的购物车*/
    @Select("SELECT h.id, h.houseType, h.num, h.joinPrice, h.ctime, ho.hotelName, ho.img\n" +
            "FROM h_hotelCart_item h\n" +
            "inner join h_hotel ho\n" +
            "on h.hotelId = ho.id\n" +
            "where h.cid = #{cid}")
    List<HotelCartItemDto> queryCart(@Param("cid") Long cid);

    /** 通过id查询购物车*/
    List<HotelCartItemDto> selectByIds(long[] ids);

    /** 下单后清空购物车*/
    /** 批处理*/
    int delBatch(List<Long> ids);
}
